/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Portions created by the Initial Developer are
 * Copyright (C) 2012 the Initial Developer.
 * All Rights Reserved.
 *
 * The Original Code is this.
 *
 * The Initial Developer of the Original Code is the author below.
 */
/**
 * @file InitialEvent.cpp
 * @brief auto generated.
 * @author K.Ozaki
 * @date 2011/07/21
 */

#include "semi/InitialEvent.h"

namespace semi {

InitialEvent::InitialEvent() {
}

InitialEvent::~InitialEvent() {
}

void InitialEvent::startup() {

    conf::Configurator::setIninitial();

    conf::Configurator conf;

    posix::MessageTimer::clearCurrentTimerIds();
    posix::MessageQue::clearCurrentQueNames(); // mq_unlink

    // logger(log printer) terminate.
    semi::logg::Logger::terminateAll();

    logg::Logger log = logg::Logger::getLogger("INITIALIZE");
    log.debug("InitialEvent::startup begin.");
    log.debug(conf::Configurator::toString());

    conf::Configurator::TaskConfigs tconfs = conf.getTaskConfigs();
    //    MessageEvent::terminateAll(tconfs);

    SharedContext::releaseAllLocks();
    SessionContext::terminateAll();

    TaskManager::setAliveAll(tconfs);

    // file etc.
    semi::conf::Configurator::BaseConfig bcnf = conf.getBaseConfig();
    if (bcnf.lock_timeout < 0)
        log.info("InitialEvent::startup no lock_timeout for shared memory.");

    // for db option
    conf::DataSourceConfig cnfdb;
    if (cnfdb.setSharedMemory())
        log.debug(conf::DataSourceConfig::toString());

    // for net option
    conf::NetConfig cnfnt;
    if (cnfnt.setSharedMemory())
        log.debug(conf::NetConfig::toString());

    log.info("InitialEvent::startup end.");
}

}
